<?php
/**
 * 分享相关
 */
namespace App;
defined('IN_IA') or exit('Access Denied');

use Control\MemberControl;
use Control\RedControl;
use Control\ShareIdControl;

class Share extends Action
{
    private $ShareId = null;
    private $Red = null;

    public function __construct()
    {
        parent::__construct();
        $this->ShareId = new ShareIdControl();
        $this->getUid();
    }

    /**
     * 通过分享id获取用户id和红包red_id
     * @param string share_id 分享id
     */
    public function find()
    {
        $_data = $this->ShareId->find($this->_gpc["share_id"]);
        if($_data){
            $this->_result = array("status"=>"success","data"=>$_data);
        }
        $this->result($this->_result);
    }

    /**
     * 红包分享参数
     * @param integer red_id 红包id
     */
    public function red()
    {
        $this->Red = new RedControl();
        $_red = $this->Red->find($this->_gpc["red_id"]);
        if($_red){
            $Member = new MemberControl();
            $_member = $Member->find($this->_uid);
            $_share_id = $this->ShareId->findId($this->_uid,$this->_gpc["red_id"]);
            $_share = array(
                'title'=>$_red['title'],
                'desc'=>$_member['nickname'].'的红包',
                'link'=>murl('entry//index',array('m'=>'kuyuan_red','share_id'=>$_share_id),true,true),
                'imgUrl'=>tomedia($_red['cover'])
            );
            $this->_result = array('status'=>'success','data'=>$_share);
        }
        $this->result($this->_result);
    }
}